home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / Keymap.java < prev    next >
Text File  |  1998-06-30  |  4KB  |  142 lines

  1. /*
  2.  * @(#)Keymap.java    1.10 98/04/09
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.text;
  21.  
  22. import com.sun.java.swing.Action;
  23. import com.sun.java.swing.KeyStroke;
  24.  
  25. /**
  26.  * A collection of bindings of KeyStrokes to actions.  The
  27.  * bindings are basically name-value pairs that potentially 
  28.  * resolve in a hierarchy.  
  29.  *
  30.  * @author  Timothy Prinzing
  31.  * @version 1.10 04/09/98
  32.  */
  33. public interface Keymap {
  34.  
  35.     /**
  36.      * Fetches the name of the set of key-bindings.
  37.      *
  38.      * @return the name
  39.      */
  40.     public String getName();
  41.  
  42.     /**
  43.      * Fetches the default action to fire if a 
  44.      * key is typed (i.e. a KEY_TYPED KeyEvent is received)
  45.      * and there is no binding for it.  Typically this
  46.      * would be some action that inserts text so that 
  47.      * the keymap doesn't require an action for each 
  48.      * possible key.
  49.      *
  50.      * @return the default action
  51.      */
  52.     public Action getDefaultAction();
  53.  
  54.     /**
  55.      * Set the default action to fire if a key is typed.
  56.      *
  57.      * @param a the action
  58.      */
  59.     public void setDefaultAction(Action a);
  60.  
  61.     /**
  62.      * Fetches the action appropriate for the given symbolic
  63.      * event sequence.  This is used by JTextController to 
  64.      * determine how to interpret key sequences.  If the
  65.      * binding is not resolved locally, an attempt is made
  66.      * to resolve through the parent keymap, if one is set.
  67.      *
  68.      * @param key the key sequence
  69.      * @returns  the action associated with the key
  70.      *  sequence if one is defined, otherwise null
  71.      */
  72.     public Action getAction(KeyStroke key);
  73.  
  74.     /**
  75.      * Fetches all of the keystrokes in this map that
  76.      * are bound to some action.
  77.      *
  78.      * @return the list of keystrokes
  79.      */
  80.     public KeyStroke[] getBoundKeyStrokes();
  81.  
  82.     /**
  83.      * Fetches all of the actions defined in this keymap.
  84.      *
  85.      * @return the list of actions
  86.      */
  87.     public Action[] getBoundActions();
  88.  
  89.     /**
  90.      * Fetches the keystrokes that will result in 
  91.      * the given action.
  92.      *
  93.      * @param a the action
  94.      * @return the list of keystrokes
  95.      */
  96.     public KeyStroke[] getKeyStrokesForAction(Action a);
  97.  
  98.     /**
  99.      * Determines if the given key sequence is locally defined.
  100.      *
  101.      * @param key the key sequence
  102.      * @return true if the key sequence is locally defined else false
  103.      */
  104.     public boolean isLocallyDefined(KeyStroke key);
  105.  
  106.     /**
  107.      * Adds a binding to the keymap.
  108.      *
  109.      * @param key the key sequence
  110.      * @param a the action
  111.      */
  112.     public void addActionForKeyStroke(KeyStroke key, Action a);
  113.  
  114.     /**
  115.      * Removes a binding from the keymap.
  116.      *
  117.      * @param keys the key sequence
  118.      */
  119.     public void removeKeyStrokeBinding(KeyStroke keys);
  120.  
  121.     /** 
  122.      * Removes all bindings from the keymap.
  123.      */
  124.     public void removeBindings();
  125.  
  126.     /**
  127.      * Fetches the parent keymap used to resolve key-bindings.
  128.      *
  129.      * @return the keymap
  130.      */
  131.     public Keymap getResolveParent();
  132.  
  133.     /**
  134.      * Sets the parent keymap, which will be used to 
  135.      * resolve key-bindings.
  136.      *
  137.      * @param parent the parent keymap
  138.      */
  139.     public void setResolveParent(Keymap parent);
  140.  
  141. }
  142.